package com.ccc3gc.serves.impl;

import com.ccc3gc.dao.UserDao;
import com.ccc3gc.dao.impl.UserDaoImpl;
import com.ccc3gc.entity.User;
import com.ccc3gc.serves.UserServes;

import java.util.List;

public class UserServesImpl implements UserServes {
    UserDao userDao = new UserDaoImpl();

    @Override
    public String queryUserNameS(String keyWord) {
        List<User> users = userDao.selectUserByKeyWord(keyWord);
        StringBuilder sb = new StringBuilder();
        for (User user : users) {
            sb.append(user.getUserName()).append(",");
        }
        String s = sb.toString();
        if (s.isEmpty()) {
            return s;
        }
        return s.substring(0, s.length() - 1);
    }
}
